package itdfq.dfq.Creational_Pattern.SingletonPattern;

/**
 * @Author GocChin
 * @Date 2021/3/22 20:09
 * @Blog: itdfq.com
 * @QQ: 909256107
 */
public class StudentID {
    private static StudentID instance = null;
    private String no;
    private StudentID(){}
    public static StudentID getInstance(){
        if (instance == null){
            System.out.println("第一次申请学号，分配新的账号");
            instance=new StudentID();
            instance.setStudentCardNo("18031210111");
        }else{
            System.out.println("对不起，此学号已经注册");
        }
        return instance;
    }
    private void setStudentCardNo(String no){
        this.no=no;
    }
    public String getStudentCardNo(){
        return this.no;
    }
}
